﻿
module("FallingLReversed.init")
test("FallingLReversed init", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    equal(5, fallingLReversed.center.x, "CenterX of FallingLReversed is set");
    equal(6, fallingLReversed.center.y, "CenterY of FallingLReversed is set");

    var relativeBody="";
    for (var i = 0; i < fallingLReversed._relativeBody.length; i++) {
        relativeBody += fallingLReversed._relativeBody[i].coordinate.toString() + " ";
    }
    equal("(0,-1) (0,0) (0,1) (-1,1) ", relativeBody, "CenterY of FallingLReversed is set");

    var body= "";
    for (var i = 0; i < fallingLReversed.getBody.length; i++) {
        body += fallingLReversed.getBody[i].coordinate.toString() + " ";
    }
    equal("(5,5) (5,6) (5,7) (4,7) ", body, "CenterY of FallingLReversed is set");
});

test("FallingLReversed moveTo", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.moveTo(7, 8);

    deepEqual(7, fallingLReversed.center.x, "CenterX of FallingLReversed is set to new x");
    equal(8, fallingLReversed.center.y, "CenterY of FallingLReversed is set to new y");

    var relativeBody = "";
    for (var i = 0; i < fallingLReversed._relativeBody.length; i++) {
        relativeBody += fallingLReversed._relativeBody[i].coordinate.toString() + " ";
    }
    equal("(0,-1) (0,0) (0,1) (-1,1) ", relativeBody, "CenterY of FallingLReversed is set");

    var body = "";
    for (var i = 0; i < fallingLReversed.getBody.length; i++) {
        body += fallingLReversed.getBody[i].coordinate.toString() + " ";
    }
    equal("(7,7) (7,8) (7,9) (6,9) ", body, "CenterY of FallingLReversed is set");
});

test("FallingLReversed moveRight", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.moveRight(); 
    deepEqual(6, fallingLReversed.center.x, "CenterX of FallingLReversed is set to x+1");
    equal(8, fallingLReversed.center.y, "CenterY of FallingLReversed is same");
});

test("FallingLReversed moveLeft", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.moveLeft();
    deepEqual(4, fallingLReversed.center.x, "CenterX of FallingLReversed is set to x-1");
    equal(8, fallingLReversed.center.y, "CenterY of FallingLReversed is same");
});

test("FallingLReversed moveUp", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.moveUp();
    equal(5, fallingLReversed.center.x, "CenterX of FallingLReversed is same");
    equal(7, fallingLReversed.center.y, "CenterY of FallingLReversed is set to y-1");
});

test("FallingLReversed moveDown", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.moveDown();
    equal(5, fallingLReversed.center.x, "CenterX of FallingLReversed is same");
    equal(9, fallingLReversed.center.y, "CenterY of FallingLReversed is set to y+1");
});

test("FallingLReversed rotate", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.rotate();
    equal(90, fallingLReversed.rotation, "Rotation of FallingLReversed is set to 90");
});

test("FallingLReversed rotate twice", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.rotate();
    equal(90, fallingLReversed.rotation, "Rotation of FallingLReversed is set to 90");
    fallingLReversed.rotate();
    equal(180, fallingLReversed.rotation, "Rotation of FallingLReversed is set to 180");
});

test("FallingLReversed rotateBack", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.rotateBack();
    equal(270, fallingLReversed.rotation, "Rotation of FallingLReversed is set to 270");   
});

test("FallingLReversed rotateTo", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingLReversed = new tetris.FallingLReversed(x, y, color);
    fallingLReversed.rotateTo(180);
    equal(180, fallingLReversed.rotation, "Rotation of FallingLReversed is set to 180");
});

